#include "Candy.h"
#include <sstream>
#include <string>
#include "Constantes.h"

Candy::Candy(Color color = NONE, std::string jsonName = "")  {
    this->color = color;
    this->jsonName = jsonName;
    this->orientacion = NO_ORIENTABLE;
    this->setEstable();
}

Candy::~Candy() { }

Color Candy::getColor() {
    return color;
}

void Candy::setEstable(){
    this->estado=CANDY_ESTABLE;
}

void Candy::setMagico(){
    this->estado=CANDY_MAGICO;
}

bool Candy::esEstable(){
    return this->estado==CANDY_ESTABLE;
}

bool Candy::esMagico(){
    return this->estado==CANDY_MAGICO;
}

std::string Candy::getJsonName() {
    return jsonName;
}

std::string Candy::getColorAsString(){
    std::string color;
    switch (this->color){
        case RED: color=CRED; break;
        case BLUE: color=CBLUE; break;
        case YELLOW: color=CYELLOW; break;
        case VIOLET: color=CVIOLET; break;
        case GREEN: color=CGREEN; break;
        case NONE: color=INCOLORO; break;
        default: color=CINVALIDO;
    }
return color;
}

std::string Candy::aString(bool detallado){
    std::stringstream ss;

    ss << this->getJsonName();
    if (this->orientable())
      	ss << "-" << this->getOrientacion();
    if (this->esMagico())
        ss << "M";

    if (detallado)
        ss << '|' << this->getColor();

return ss.str();
}

bool Candy::orientable(){
return false;
}

bool Candy::eliminable(){
return true;
}

bool Candy::movible(){
return true;
}

t_orientacion Candy::getOrientacion(){
return this->orientacion;
}

void Candy::setOrientacion(t_orientacion orientacion){
 this->orientacion=orientacion;
}
